Execute Events
The setEvent
function is used to execute an available intermediate Event in Bizagi, which has no specific type defined.
For example, it can be used on an expression related to a button to execute an intermediate event in my process. The function can execute events in the active process or in an external process.
Syntax
CHelper.setEvent(Me,Caseid,"Event name",null)
Main Parameters
- Caseid: the identification number of the Case in which the Event will be triggered.
- Event Name: the name of the event to be executed.
- Me and null: fixed parameters.
Note
There is a method override that receives an XML as a parameter:
CHelper.setEvent(XML)
The setEvent
function is found in the Process category.
Example: Help Desk Process
Once a case is created, an Event is enabled that allows the case to be closed at any time, as shown in the process flow below.
The Analyze and Resolve Task contains a button that will close the case automatically if clicked.
This button will call the Close Case Event. The process flow will reach the End Event and the case will be closed.
Configuring the Case Closing Event
Follow these steps to configure:
-
Go to the form of the Analyze and Resolve Task, include a new button, and name it Close Case.
Create an action (from Actions and validations) when the button is clicked, then select execute rule in the Then block.
-
In the argument, click on New and then include an Expression module.
Select thesetEvent
function. -
Value the parameters of the
setEvent
function.
The Caseid is obtained using theMe.Case.Id
function which returns the ID of the current case.
The Event Name is
CloseCase
.
You can verify the name in the Event properties of the Task by going to the first step of the Process Wizard.
CHelper.setEvent(Me,Me.Case.Id,"CloseCase",null);
This similarly, with the XML method would be. You can use the Case Number, for example, when you use customized cases, using the (radNumber) tag.
var XML = "<BizAgiWSParam>"
+"<domain>domain</domain>"
+"<userName>Admon</userName>"
+"<Events>"
+"<Event>"
+"<EventData>"
+"<radNumber>" + Me.Case.CaseNumber + "</radNumber>"
+"<eventName>CloseCase</eventName>"
+"</EventData>"
+"<Entities></Entities>"
+"</Event>"
+"</Events>"
+"</BizAgiWSParam>";
CHelper.setEvent(XML);
Or you can use the XML with the case ID using the idCase tag.
var XML = "<BizAgiWSParam>"
+"<domain>domain</domain>"
+"<userName>Admon</userName>"
+"<Events>"
+"<Event>"
+"<EventData>"
+"<idCase>" + Me.Case.Id + "</idCase>"
+"<eventName>CloseCase</eventName>"
+"</EventData>"
+"<Entities></Entities>"
+"</Event>"
+"</Events>"
+"</BizAgiWSParam>";
CHelper.setEvent(XML)
Save the expression. When you click on the Close Case button from the Work Portal, the case will be closed.